package com.hjj.emp.service.impl;

import com.hjj.emp.dao.EmpMangerDao;
import com.hjj.emp.dao.impl.EmpManagerDaoImpl;
import com.hjj.emp.entity.EmpManager;
import com.hjj.emp.service.EmpManagerService;
import com.hjj.emp.utils.DbUtils;

/**
 * @author Layton
 * @version 1.0
 * @date 2021/3/12 19:43
 */
public class EmpManagerServiceImpl implements EmpManagerService {
    private EmpMangerDao empManagerDao = new EmpManagerDaoImpl();
    @Override
    public EmpManager login(String username, String password) {
        EmpManager empManager = null;
        try {
            DbUtils.begin();
            EmpManager tmp = empManagerDao.select(username);
            if(tmp != null){
                if(tmp.getPassword().equals(password)){
                    empManager = tmp;
                }
            }
            DbUtils.commit();
        } catch (Exception e) {
            DbUtils.rollback();
            e.printStackTrace();
        }
        return empManager;
    }
}
